package com.xiaohe66.web.infrastructure.mybatis.im.convert;

import com.xiaohe66.web.domain.im.agg.Message;
import com.xiaohe66.web.domain.im.value.MessageUnread;
import com.xiaohe66.web.infrastructure.domain.adapter.im.MessageConverter;
import com.xiaohe66.web.infrastructure.mybatis.im.model.MessageDo;
import com.xiaohe66.web.infrastructure.mybatis.im.model.MessageUnreadDo;
import com.xiaohe66.web.integration.DoConverter;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * @author xiaohe
 * @since 2023-08-09 16:00
 */
@Mapper(componentModel = "spring")
public interface MessageDoConverter extends MessageConverter, DoConverter<Message, MessageDo> {

    @Mapping(target = "qty", expression = "java(newId(messageUnreadDo.getQty()))")
    MessageUnread toEntity(MessageUnreadDo messageUnreadDo);

    List<MessageUnread> toEntity(List<MessageUnreadDo> list);
}
